package com.weixing.mall.provider.job;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.weixing.mall.provider.api.service.ProductStockServiceRpc;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class ProductStockReportJob extends QuartzJobBean {
    @Autowired
    private ProductStockServiceRpc productStockServiceRpc;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        DateTime dateTime = new DateTime();
        //定时任务是每月1号00:00:00执行，保存为上月的截留
        String yearMonth = DateUtil.format(DateUtil.offsetMonth(dateTime,-1),"yyyy-MM");
         productStockServiceRpc.updateSynData(yearMonth);
         System.out.println("库存数据同步任务执行："+yearMonth);
    }
}
